<template>
  <div class="app-container">
    <div slot="header" class="clearfix">
      <span class="el-icon-document">复学证明</span>
      <el-button style="float: right" size="mini" type="danger" @click="goBack">关闭</el-button>
      <el-button style="float: right" size="mini" type="success" v-print="printobj">打印</el-button>
      <el-button style="float: right" size="mini" type="success" @click="pdfExport">导出休学证明</el-button>
    </div>
    <div id="quitSchool" class="certificate">
      <h1>复学证明</h1>
      <h4>桂水电院 {{ form.quitYear }} 复字第 {{ form.quitNumber }}号</h4>
      <p>
        {{ form.stuName }},{{ form.gender }},{{ form.mz }},{{ form.birthday }}出生，{{ form.jg }}人，{{ form.className }}学生，学号：{{ form.stuNo }}。该生于{{ form.quitTime }}日因{{ reentryFormat(form) }}，申请休学。于{{ form.reentryTime }} 申请复学。{{
          form.instructionSchoolHours
        }}在校时间为XX个月。经学校研究，同意复学，安排在{{ form.className }} 学习。
      </p>
      <p>抄送：教务处、财务处、{{ form.departmentName }}</p>
      <div class="stamp">
        <img src="../../../assets/logo/stamp.png" alt="" />
        <div>
          <span>学生工作处</span>
          <span>{{ form.reentryTime }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getRtStuReentrySchool } from '@/api/routine/rtStuReentrySchool'
import { getClass } from '@/api/stuCQS/basedata/class'
import { formatDateByYearMonthDay } from '/src/utils/index'

export default {
  dicts: ['rt_quit_type', 'rt_submission_status', 'rt_quit_apply_status', 'rt_transaction_type'],
  name: 'RtStuReentrySchoolProve',
  data() {
    return {
      form: {
        reentryId: null,
        stuNo: null,
        stuName: null,
        stuId: null,
        gender: null,
        departmentName: null,
        gradeName: null,
        className: null,
        mz: null,
        birthday: null,
        parentPhone: null,
        parentName: null,
        jg: null,
        hksz2: null,
        attachmentUpload: null,
        reasonApplying: null,
        applySignature: null,
        applyStatus: null,
        submissionStatus: null,
        reentryType: null,
        quitNumber: null,
        processInstanceId: null,
        deployId: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        ideologicalEducation: null,
        instructionSchoolHours: null,
        ihandlingSuggestion: null,
        quitTime: null,
        reentryTime: null,
        reentryClass: null,
        reentryDept: null,
        reentryCause: null,
        reentryYear: null,
        reentryNumber: null,
        quitType: null,
        className: null,
      },
      //打印
      printobj: {
        id: 'quitSchool',
        popTitle: '打印', // 打印配置页上方标题
        extraHead: '', //最上方的头部文字，附加在head标签上的额外标签,使用逗号分隔
        preview: '', // 是否启动预览模式，默认是false（开启预览模式，可以先预览后打印）
        previewTitle: '', // 打印预览的标题（开启预览模式后出现）,
        previewPrintBtnLabel: '', // 打印预览的标题的下方按钮文本，点击可进入打印（开启预览模式后出现）
        zIndex: '', // 预览的窗口的z-index，默认是 20002（此值要高一些，这涉及到预览模式是否显示在最上面）
        previewBeforeOpenCallback() {}, //预览窗口打开之前的callback（开启预览模式调用）
        previewOpenCallback() {}, // 预览窗口打开之后的callback（开启预览模式调用）
        beforeOpenCallback() {}, // 开启打印前的回调事件
        openCallback() {}, // 调用打印之后的回调事件
        closeCallback() {}, //关闭打印的回调事件（无法确定点击的是确认还是取消）
        url: '',
        standard: '',
        extraCss: '',
      },
    }
  },
  created() {
    if (this.$route.query.reentryId) {
      let reentryId = this.$route.query.reentryId
      getRtStuReentrySchool(reentryId).then((response) => {
        this.form = response.data
        this.form.birthday = formatDateByYearMonthDay(this.form.birthday)
        this.form.quitStartTime = formatDateByYearMonthDay(this.form.quitStartTime)
        this.form.quitEndTime = formatDateByYearMonthDay(this.form.quitEndTime)
      })
      this.getClass()
    }
  },
  methods: {
    getClass() {
      getClass(this.form.reentryClass).then((res) => {
        this.form.className = res.data.className
      })
    },
    quittypeFormat(row, column) {
      return this.selectDictLabel(this.dict.type.rt_quit_type, row.quitType)
    },
    reentryFormat(row, column) {
      return this.selectDictLabel(this.dict.type.rt_transaction_type, row.quitType)
    },
    pdfExport() {
      // 导出时，隐藏公章
      this.htmlToPdf('quitSchool', '复学证明')
    },
    /** 返回页面 */
    goBack() {
      // 关闭当前标签页并返回上个页面
      // const obj = { path: '/routine/relieve', query: { t: Date.now() } }
      // this.$tab.closeOpenPage(obj)
      this.$router.back()
      // 关闭窗体 index 当前层索引
      this.$tab.closePage()
    },
  },
}
</script>

<style scoped lang="scss">
.certificate {
  padding: 0 50px;
  position: relative;

  h1 {
    text-align: center;
    font-size: 34px;
  }

  h4 {
    text-align: center;
    color: #868585;
  }

  p {
    text-indent: 32px;
    line-height: 30px;
    color: #333;
    letter-spacing: 2px;
  }

  .stamp {
    position: relative;
    height: 115px;
    margin-top: 50px;
    display: flex;
    flex-direction: column;
    color: #333;
    line-height: 35px;
    letter-spacing: 3px;
    align-items: flex-end;

    &>div {
      display: flex;
      flex-direction: column;
      margin-right: 28px;
    }

    img {
      width: 180px;
      height: 180px;
      top: -54px;
      position: absolute;
      z-index: -1;
    }

  }
}
</style>
